public class Main {
    public static void main(String[] args) {
        Person[] p = new Person[10];
        p[0] = new Person();
        p[1] = new Person();
        p[2] = new Person();
        p[0].setName("zhangsan");
        p[0].setAge(18);
        p[1].setName("lisi");
        p[1].setAge(20);
        p[2].setName("wangwu");
        p[2].setAge(22);
        for (int i = 0; i < p.length; i++) {
            if (p[i] != null) {
                System.out.println(p[i].getName() + " " + p[i].getAge());
            }
        }
    }
}

class Person {

    public Person() {
    }

    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}